useConfig
The useConfig hook provides access to the viewer configuration in the @promaton/scan-viewer library. It can be easily initialized via the <Viewer /> component's config prop.
Interface: ConfigStore
The useConfig hook is based on the ConfigStore interface, which extends ConfigStoreOptions. Below is a detailed breakdown of its properties and methods.
Properties
axisDirection
- Type:
AxisDirectionType - Specifies whether the up axis is
YorZ.
composerFactory
- Type:
undefined | ViewerComposerFactory - Overrides the default factory for a view's render pipeline.
customSliceMovements
- Type:
object - Defines allowed movements of the custom slice plane.
depth:boolean(default:true) - Movement in the direction of the plane.pitch:boolean(default:true) - Rotation around the x-axis.yaw:boolean(default:true) - Rotation around the vertical (y) axis.
enableAdvancedMaterialControls
- Type:
boolean(default:false) - Enables editing of material properties like roughness and metalness.
enableAutomaticCameraMovement
- Type:
boolean(default:false) - Animates the camera when the selection changes.
enableCrossSectionControls
- Type:
boolean(default:true) - Allows editing whether the mesh is cross-sectioned.
enableCustomSliceTransformControls
- Type:
boolean(default:true) - Displays custom slice transform controls in the 3D viewport when the custom slice is visible.
enableIntersectionHeatmaps
- Type:
boolean(default:false) - Renders heatmaps for intersections when using editing tools.
enableLighting
- Type:
boolean(default:true) - Enables or disables default lighting.
enableLoadingIndicator
- Type:
boolean(default:true) - Enables the automatic loading indicator widget.
enableMeasurements
- Type:
boolean(default:true) - Enables the measurements widget in the viewer.
enableObjectDeletion
- Type:
boolean(default:false) - Allows users to delete objects from the scene via the object editor.
enableObjectEditing
- Type:
boolean(default:true) - Enables an object editor UI for editing objects in the viewer or layer list.
enableObjectGroupEditing
- Type:
boolean(default:true) - Allows changing the group of selected objects.
enableObjectSelection
- Type:
boolean(default:true) - Enables focusing on specific objects when double-clicked in the viewer or clicked in the layer list.
enableOrientationExclusions
- Type:
boolean(default:true) - Allows editing the orientations in which an object is visible.
enableOrthogonalPlaneVisualizationIn3DView
- Type:
boolean(default:true) - Displays indications of orthogonal slice positions in the 3D view when using multiple views.
enablePlaneAnimation
- Type:
boolean(default:true) - Smoothly interpolates plane positions.
enableSelectionToolWindow
- Type:
boolean(default:true) - Displays a tool window when a selection is active and no other tools are in use.
enableTransforms
- Type:
boolean(default:true) - Adds tools to edit the translation and rotation of objects with transform properties.
enableWireframe
- Type:
boolean(default:false) - Displays a wireframe overlay on meshes.
expandGroupsByDefault
- Type:
boolean(default:false) - Determines whether groups in the layer list are open by default.
geometryProcessing
- Type:
object - Configures how geometry is processed after initial load.
creaseAngle:null | number(default:Math.PI / 6) - Creates sharp edges when the angle between polygons exceeds this value.mergeMode:MergeMode- Determines how loaded meshes are merged during asynchronous processing.
maxLandmarkDistanceFromSlicePlane
- Type:
number(default:0.3) - Hides landmarks in 2D views when they are further from the slice than this threshold.
objectAxisStyle
- Type:
object - Styling for object axes when visible.
color:string(default:"#2b3ab8")lengthFactor:number(default:5)lineColor:string(default:"#ffffff")opacity:number(default:0.8)opacityBehind:number(default:0.3)
orthogonalPlanesStyle
- Type:
object - Styling for orthogonal plane lines in 2D slice views.
hoverFactor:numberopacity:number(default:0.9)thickness:number(default:3)visible:boolean(default:true)
preloadHiddenObjects
- Type:
boolean(default:false) - Determines whether to pre-load hidden objects.
requestHeaderGetter
- Type:
undefined | () => Promise<Record<string, string>> - Provides custom request headers for the viewer's file loaders.
resolutionScale
- Type:
number | "auto" - Adjusts the render resolution scale during interaction.
selectionOutline
- Type:
object - Configures the style of the outline displayed around selected objects.
color:string(default:"#0a8af3")width:number(default:1)
showKeypointsOnTubeLandmarks
- Type:
boolean(default:true) - Displays the position and radius of keypoints for tube landmarks like nerves.
showObjectAxis
- Type:
"highlight" | "always" | "never" - Determines when to show the object axis. Default:
"highlight".
sliceFallOff
- Type:
number(default:7.5) - Defines the fade-out effect for objects with
showMeshInSlices.
Methods
resetConfig()
- Description: Resets the configuration to its default values.
- Returns:
void
updateConfig(config)
- Description: Updates the configuration with the provided values. Deeply merges the new values with the current configuration.
- Parameters:
config:PartialObjectDeep<ConfigStore>
- Returns:
void
Usage Example
import { useConfig } from "@promaton/scan-viewer";
const ViewerComponent = () => {
const config = useConfig();
// Update configuration
config.updateConfig({ enableLighting: false });
return <div>Viewer Component</div>;
};
The useConfig hook is a powerful tool for customizing the viewer's behavior and appearance. Use it to tailor the viewer to your application's specific needs.